package com.graph;

import java.awt.Color;
import java.awt.Graphics;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Drawing {
	//School
	ArrayList<Shape> shapes = new ArrayList<Shape>();
	
	
	public void AddCircle(Shape c) {
		shapes.add(c);
		
	}
	public void remove(Circle c) {
		
	}
	
	
	public void save(String path){
		String jsontext = null;
		   ObjectMapper mapper = new ObjectMapper();
		   try {
			   
			jsontext =  mapper.writeValueAsString(shapes);
			
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	public void saveToFile(String path){
		String jsontext = null;
		   ObjectMapper mapper = new ObjectMapper();
		   try {
			   
			OutputStream  out = new FileOutputStream("d:/drawing.json");
			
			jsontext =  mapper.writeValueAsString(shapes);
			
			out.write(jsontext.getBytes());
			out.close();
			
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public void paint(Graphics g) {
		
		for(int i = 0; i < shapes.size(); i++) {
			
			Shape s = shapes.get(i);
			s.paint(g);

		}
		
	}
}
